From: Carlos Garcia Campos Date: Tue, 16 Dec 2025 14:33:34 +0000 (+0100) Subject: Disable DMABuf renderer for NVIDIA proprietary drivers X-Git-Tag: archive/raspbian/2.50.4-1+rpi1^2~1 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=3816eff3abf7a6d07653e264a6e023eef0e882d9;p=webkit2gtk.git Disable DMABuf renderer for NVIDIA proprietary drivers Bug: https://bugs.webkit.org/show_bug.cgi?id=262607 Bug-Debian: https://bugs.debian.org/1039720 Origin: https://github.com/WebKit/WebKit/pull/18614 Gbp-Pq: Name disable-nvidia-dmabuf.patch --- diff --git a/Source/WebKit/UIProcess/gtk/AcceleratedBackingStore.cpp b/Source/WebKit/UIProcess/gtk/AcceleratedBackingStore.cpp index 8345d7f789..0964ee5902 100644 --- a/Source/WebKit/UIProcess/gtk/AcceleratedBackingStore.cpp +++ b/Source/WebKit/UIProcess/gtk/AcceleratedBackingStore.cpp @@ -39,9 +39,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -54,6 +56,7 @@ #if USE(GBM) #include #include +#include #include static constexpr uint64_t s_dmabufInvalidModifier = DRM_FORMAT_MOD_INVALID; @@ -79,6 +82,54 @@ using namespace WebCore; WTF_MAKE_TZONE_ALLOCATED_IMPL(AcceleratedBackingStore); +static bool isNVIDIA() +{ + const char* forceDMABuf = getenv("WEBKIT_FORCE_DMABUF_RENDERER"); + if (forceDMABuf && *forceDMABuf != '0') + return false; + + std::unique_ptr platformDisplay; +#if USE(GBM) + UnixFileDescriptor fd; + struct gbm_device* device = nullptr; + const char* disableGBM = getenv("WEBKIT_DMABUF_RENDERER_DISABLE_GBM"); + if (!disableGBM || *disableGBM == '0') { + auto drmDevice = drmMainDevice(); + if (!drmDevice.isNull()) { + const auto& filename = !drmDevice.renderNode.isNull() ? drmDevice.renderNode : drmDevice.primaryNode; + fd = UnixFileDescriptor { open(filename.data(), O_RDWR | O_CLOEXEC), UnixFileDescriptor::Adopt }; + if (fd) { + device = gbm_create_device(fd.value()); + if (device) + platformDisplay = PlatformDisplayGBM::create(device); + } + } + } +#endif + if (!platformDisplay) + platformDisplay = PlatformDisplaySurfaceless::create(); + + bool returnValue = false; + GLDisplay* glDisplay = platformDisplay ? &platformDisplay->glDisplay() : Display::singleton().glDisplay(); + if (glDisplay) { + auto targetType = platformDisplay && platformDisplay->type() == PlatformDisplay::Type::Surfaceless ? GLContext::Target::Surfaceless : GLContext::Target::Default; + GLContext::ScopedGLContext glContext(GLContext::create(*glDisplay, targetType, nullptr)); + const char* glVendor = reinterpret_cast(glGetString(GL_VENDOR)); + if (glVendor && strstr(glVendor, "NVIDIA")) + returnValue = true; + } + + if (platformDisplay) + platformDisplay->clearGLContexts(); + +#if USE(GBM) + if (device) + gbm_device_destroy(device); +#endif + + return returnValue; +} + OptionSet AcceleratedBackingStore::rendererBufferTransportMode() { static OptionSet mode; @@ -94,6 +145,9 @@ OptionSet AcceleratedBackingStore::rendererBufferTr return; } + if (isNVIDIA()) + return; + mode.add(RendererBufferTransportMode::SharedMemory); const char* forceSHM = getenv("WEBKIT_DMABUF_RENDERER_FORCE_SHM");